<template>
  <div class="setting-shan-container">
    <div class="applet-blendent-header">设置UU跑腿信息</div>
    <el-form :model="uuData" label-width="170px" size="small" style="margin: 20px auto">
      <el-form-item label="appid">
        <el-input v-model="uuData.appid" placeholder="请输入" style="width: 40%"/>
      </el-form-item>
      <el-form-item label="appkey">
        <el-input v-model="uuData.appkey" placeholder="请输入" style="width: 40%"/>
      </el-form-item>
      <el-form-item label="openid">
        <el-input v-model="uuData.openid" placeholder="请输入" style="width: 40%"/>
      </el-form-item>
    </el-form>

    <div style="text-align:center;margin-top:15px">
      <el-button type="primary" size="small" style="padding:8px 30px;" @click="submit">提 交</el-button>
    </div>
  </div>
</template>

<script>
import { getUU, postUU } from '@/api/setting'

export default {
  name: 'setting-shansong',
  data() {
    return {
      uuData: { id: '', appid: '', appkey: '', openid: '' },
    }
  },
  mounted() {
    this.getUU();
  },
  methods: {
    getUU() {
      getUU({key: this.$store.state.app.activeApp.saa_key}).then(res => {
        if(res.status === 200) {
          this.uuData.id = res.data.id;
          this.uuData.appid = res.data.appid;
          this.uuData.appkey = res.data.appkey;
          this.uuData.openid = res.data.openid;
        }else{
          this.$message.error(res.message);
        }
      })
    },
    submit() {
      const params = {
        id: this.uuData.id,
        key: this.$store.state.app.activeApp.saa_key,
        appid: this.uuData.appid,
        appkey: this.uuData.appkey,
        openid: this.uuData.openid,
      };

      postUU(params).then(res => {
        if(res.status === 200) {
          this.$message.success('修改成功！');
        }else{
          this.$message.error(res.message);
        }
      })
    }
  },
}
</script>

<style lang="scss" scoped>
.setting-shan-container{
  min-height: calc(100vh - 100px);
  margin: 20px;
  background-color: #fff;
  padding:25px;
  box-shadow: 0px 0px 4px 0px rgba(115, 115, 115, 0.2);
}
.applet-blendent-header{
  height: 40px;
  width: 100%;
  line-height: 40px;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 2px;
  color: #8f8f8f;
  padding: 0 10px;
  background-color: #F4F8FB;
}
</style>
